
import socket
from urls import urlpatterns
from threading import Thread

server = socket.socket()

server.bind(('127.0.0.1',8003))
# 127.0.0.1:8001
server.listen()



while 1:

    conn,addr = server.accept()

    from_brower_msg = conn.recv(1024)
    # print(from_brower_msg)
    path = from_brower_msg.decode('utf-8').split(' ')[1]
    print(path)
    conn.send(b'HTTP/1.1 200 ok\r\n\r\n')

    for url in urlpatterns:
        if path == url[0]:
            # ret = url[1]()
            t = Thread(target=url[1],args=(conn,))
            t.start()
            break




